const USER_TOKEN = "ttyg-2022-01-17";
const USER_INFO_NICKNAME = "user_info_nickname-2022-01-17";
const USER_INFO_AVATARURL = "user_info_avatarurl-2022-01-17";

const state = {
    token: uni.getStorageSync(USER_TOKEN) || '',
    // userInfo: Object.keys(uni.getStorageSync(USER_INFO)).length > 0 ? uni.getStorageSync(USER_INFO) : {}
    avatarUrl: uni.getStorageSync(USER_INFO_AVATARURL) || '',
    nickName: uni.getStorageSync(USER_INFO_NICKNAME) || '',
}

const mutations = {
    SET_TOKEN(state, data) {
        console.log(14,data)
        state.token = data
        uni.setStorageSync(USER_TOKEN, data);		
    },
    SET_USERINFO_NICK_NAME(state, data) {
        state.nickName = data
        uni.setStorageSync(USER_INFO_NICKNAME,data)
    },
    SET_USERINFO_AVATARURL(state, data) {
        state.avatarUrl = data
        uni.setStorageSync(USER_INFO_AVATARURL,data)
    }
}

const actions = {
    
}

export default {
    namespaced: true,
    state,
    mutations,
    actions
}